package com.zhiyu.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.zhiyu.annotation.PassToken;
import com.zhiyu.api.ReturnResult;
import com.zhiyu.service.webApi.ILoginService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@Slf4j
@RestController
@RequestMapping("api/login")
public class LoginController {

    @Reference(version = "1.0.0")
    ILoginService iLoginService;

    /**
     * 根据用户信息生成token（用户登录）
     * @param param
     * @return
     */
    @PassToken
    @RequestMapping(value = "/getTokenByUser",method = RequestMethod.POST)
    public ReturnResult getTokenByUser(@RequestBody Map<String, Object> param) {
        ReturnResult returnResult = iLoginService.getTokenByUser(param);
        return returnResult;
    }

    /**
     * 用户登出
     * @return
     */
    @PassToken
    @RequestMapping(value = "/logout",method = RequestMethod.POST)
    public Boolean logout(){
        return true;
    }

}
